var express = require('express');
var router = express.Router();

router.use('/', function (req, res, next) {
  console.log(req.method);        // GET
  console.log(req.originalUrl);
  /*
  console.log(req.baseUrl);       // /test
  console.log(req.body);          // {}
  console.log(req.cookies);       // {}
  console.log(req.fresk);         // undefined
  console.log(req.hostname);      // localhost 192.168.0.110
  console.log(req.ip);            // ::1 ::ffff:192.168.0.110
  console.log(req.ips);           // []
  console.log(req.method);        // GET
  console.log(req.originalUrl);   // /test?b=1
  console.log(req.params);        // {}
  console.log(req.path);          // /
  console.log(req.protocol);      // http
  console.log(req.query);         // {b:'1'}
  console.log(req.route);         // [Object Object]
  console.log(req.secure);        // false
  console.log(req.signedCookies); // {}
  console.log(req.stale);         // true
  console.log(req.subdomains);    // []
  console.log(req.xhr);           // false
  */
  if (req.method == 'GET') {
    res.json(Object.assign(
      { txt: 'MirrorForce' }, req.query,
    ))
  } else {
    res.json(Object.assign(
      { txt: 'MirrorForce' }, req.body,
    ))
  }
})//将发来的数据原封不动的全部原路返回

module.exports = router;
